<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
	<%@ page isELIgnored="false" %>
	<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>  
<!DOCTYPE html>
<%
	String path = request.getContextPath();
%>
<html>
<head>

<link rel="stylesheet" type="text/css"
	href="<%=path%>/script/easyUI-1.4/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css"
	href="<%=path%>/script/easyUI-1.4/themes/icon.css">
<script type="text/javascript"
	src="<%=path%>/script/easyUI-1.4/jquery-3.2.1.min.js"></script>
<script type="text/javascript"
	src="<%=path%>/script/easyUI-1.4/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="<%=path%>/script/easyUI-1.4/locale/easyui-lang-zh_CN.js"></script>
</head>
<script type="text/javascript">

$(function(){
	
	$('#key').combobox({
		onSelect: function(record){
			var value=record.keyValue;
			$('#commitkey').textbox('setValue',value);
		}
	});
	
	
	$('#fileTree').tree({    
	    url:'<%=path%>/guancangAction/getFileTreeData'   ,
	    onSelect: function(node){
	    	if(node.text=="点击新增文件夹"){
	    		//说明用户选择的是编辑文件夹
	    		$('#fileTree').tree("beginEdit",node.target);
	    		if(node.text==""){
	    			$('#fileTree').tree('update', {
	    				target: node.target,
	    				text: '点击新增文件夹'
	    			});
	    		}
	    	}
	    	$('#wenjianjia').val(node.text);
		},
		onAfterEdit:function(node){
			$('#wenjianjia').val(node.text);
		}
	});  
	
	
	 $("#saveBtn").bind('click',function(){
		  
		  var isValid = $("#form").form('validate');
		  
		  
		  if(!isValid){
			  //表单验证失败
		  }else{
			  //说明表单验证成功，ajax提交表单
			 
			    $.ajax({
		            //几个参数需要注意一下
		                type: "POST",//方法类型
		                dataType: "json",//预期服务器返回的数据类型
		                url: "<%=path%>/userAction/saveShoucang",
		                data: $('#form').serialize(),
		                success: function (result) {
		                    	
		                	
		                    if(result.msg != null && result.msg != ""){
		                    	//保存成功
		                    	$.messager.confirm('提示',result.msg,function(r){    
		                    	  location.href="<%=path%>/views/user/main.jsp"; 
		                    	});
		                    }
		                    
		                },
		                error : function() {
		                    alert("系统异常！");
		                }
		            });
			  
			  
		  }
		  
		  
});
	
})



	function show(url){
		window.open(url);
	}
	
	function shoucang(url,title){
		
		
		$("#visible").css("visibility","visible");
		var dataParm={"url":url};
		
		 $.ajax({
	            //几个参数需要注意一下
	                type: "POST",//方法类型
	                dataType: "json",//预期服务器返回的数据类型
	                url: "<%=path%>/userAction/isShouCang",
	                data: dataParm,
	                success: function (result) {
	                	
	                	$('#title').textbox('setValue',result.title);
	                	
	                    	$('#win').window({    
	                		    width:380,    
	                		    height:500,    
	                		    modal:true ,
	                		    title:"转藏到我的图书馆"
	                		}); 
	                    
	                    
	                },
	                error : function() {
	                    alert("系统异常！");
	                }
	            });
		
		
	};
	
	
	 
	
</script>


<body>   
  
  	<c:forEach items="${spiderDataDtos}" var="article">
  		<div>
  			<font size="5px" color="#030303" onclick="show('${article.url}')" style="font-family:verdana;font-weight:bold">${article.title}</font>
  			&nbsp;&nbsp;&nbsp;<a id="shoucangBtn" onclick="shoucang('${article.url}','${article.title}')" class="easyui-linkbutton" data-options="iconCls:'icon-search'">收藏</a> 
  			<br /><br />
					   		 <font size="3px;" color="grey">${article.content} </font> 
                   
  			 
  		</div>
  		
  		<hr>
  	</c:forEach>
  
  <div id="win">   
    			<form method="post" id="form">
    			<input type="hidden" name="url" value="${article.url}">
    			<div id="visible" style="visibility: hidden;">
    				<div id="titleVisible" style="margin-top: 30px;margin-left: 30px;margin-right: 30px;">
    					<input class="easyui-textbox" name="title" style="width:100%;height: 40px;" id="title">
    				</div>
    			
		    	<div style="margin-top: 10px;margin-left: 30px;margin-right: 30px;">
					<select id="cc" class="easyui-combobox" name="quanxian" style="width:200px;height: 40px">   
					    <option value="公开">公开</option>   
					    <option value="私密">私密</option>   
					</select>  
				</div>
    			<div style="margin-top: 10px;margin-left: 30px;margin-right: 30px;">
				 	关键字:<br><br>
				 	<input class="easyui-textbox" data-options="required:true" id="commitkey" style="width:300px;height: 30px;" name="key" > <br>
				 	<input id="key" class="easyui-combobox"  data-options="valueField:'keyValue',textField:'keyText',url:'<%=path%>/guancangAction/getKey'" />  
		 
				</div>
				
				
				<div style="margin-top: 10px;margin-left: 30px;margin-right: 30px;">
					选择存放的文件夹:<br><br>
					<ul id="fileTree" data-options="required:true"></ul> 
					<input type="hidden"  name="wenjianjia" id="wenjianjia">
				</div>
    			
    			<div style="margin-top: 10px;margin-left: 30px;margin-right: 30px;">
				 	标签:<br><br>
				 	<input id="label" class="easyui-combobox" name="label" data-options="valueField:'keyValue',textField:'keyText',url:'<%=path%>/guancangAction/getLabel'" />  
				</div>
				
				<div style="margin-top: 10px;margin-left: 90px;margin-top: 30px;">
					<a id="saveBtn" class="easyui-linkbutton"
									data-options="iconCls:'icon-ok'" style="width: 80px; height: 32px;">发表</a>
								<a id="backBtn" class="easyui-linkbutton"
									data-options="iconCls:'icon-back'"
									style="width: 80px; height: 32px;margin-left: 20px">取消</a>
				</div>
    			
    			</div>
    		</form>
			</div> 
  
</body>  

</html>